<?php session_start(); include_once("../DataProvider.php");?>
	<tr style="background-color:#fafafa;" >
    	<th align="center" >Hình</th>
        <th align="left" >Tên game</th>
        <th align="right">Size</th>
        <th align="right">Giá</th>
        <th align="center">Xóa</th>
    </tr>
<?php
$arr = $_SESSION["listGame"];

if(count($arr)>0)
{	

	$page = $_GET['page'];
	$listGame1 = "";
	
	foreach($arr as $value)
	{
		$listGame1 = $listGame1.",".$value;
	}
	$listGame1 = substr($listGame1,1);

	$sql ="SELECT * FROM tbl_games WHERE GameID IN (".$listGame1." )";
	$result = DataProvider::ExecuteQuery($sql);
	if($result)
	{
	$tongsorecord = mysql_num_rows($result);
	$y = 10;
	$start = ($page-1)*$y;
	$tongsotrang = ceil($tongsorecord/$y);
	if($tongsorecord == 0){
		//echo "Không có tin nào";	
	}
	else{


	$sql1 ="SELECT * FROM tbl_games WHERE GameID IN (".$listGame1." ) order by GameName limit $start,$y";
	$result1 = DataProvider::ExecuteQuery($sql1);
	while($row1 = mysql_fetch_array($result1))
	{
		?>
		<tr>
    	<td width="80px" ><div style="background: url(<?php echo $row1["Artwork"] ?>) no-repeat; background-size:70px; float:left; "><img src="img/mask175_t.png" height="70px" width="70px" /></div></td>
        <td align="left"><?php echo $row1["GameName"] ?></td>
        <td align="right"><?php if($row1["Size"]>1000)	
	 		echo number_format($row1["Size"]/1000,2,".",","). " GB"; 
		else
			echo number_format($row1["Size"],2,".",",") . " MB";?></td>
        <td align="right"><?php echo number_format($row1["Price"], 0, '.', ',')?> VNĐ</td>
        <td align="center"><img id="delete<?php echo $row1["GameID"]  ?>" src="img/delete-big.png" height="32px" width="32px" style="cursor:pointer;display:block;" onClick="javascript:removeCart('<?php echo $row1["GameID"]  ?>')" alt="Xóa"/><img id="undelete<?php echo $row1["GameID"]  ?>" src="img/undelete.png" height="32px" width="32px" style="cursor:pointer; display:none;" onClick="javascript:addCart('<?php echo $row1["GameID"]  ?>')" alt="Không xóa"/></td>
    </tr>
<?php	}
}
?>
<tr>
<td align="right" colspan="4" bgcolor="#CCCCCC"><span style=" margin-right:1px;color:#000; background-color:#fff;border:solid;  border-color:#000; border-width:2px;">&nbsp;Trang <?php echo $page."/".$tongsotrang ?>&nbsp;</span>
<?php

       if($page == 1)
				{echo"<span class='active' style='color:#000; background-color:#fff;border:solid; border-color:#000; border-width:2px;'><<</span>";}
				else
				{
				echo"<span class='paging'><a style='text-decoration:none;' href='#1' onclick='javascript:loadCart(1);'><< </a> </span>";}
			for($i=1;$i<=$tongsotrang;$i++){
				
				if($i == $page){
				 echo "<span class='active' style=' margin-right:1px; ; background-color:#fff;border:solid; border-color:#000; border-width:2px;'>$i</span>";	
				}else{
					echo "<span class='paging'><a style='text-decoration:none;' href='#$i' onclick='javascript:loadCart($i);'> $i</a>  </span>";	
				}
			}
			if($page == $tongsotrang)
				{echo"<span class='active' style='  background-color:#fff;border:solid; border-color:#000; border-width:2px;'>>></span>";}
				else
				{
				echo"<span class='paging' ><a style='text-decoration:none;' href='#$i' onclick='javascript:loadCart($tongsotrang);'> >> </a></span>";
				}
}
}
?> </td>
</tr>